package com.baizhi.controller;


import com.baizhi.entity.Admin;
import com.baizhi.service.AdminService;
import org.aspectj.lang.annotation.After;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("admin")
public class AdminController {

    @Autowired
    private AdminService adminService;
    @Autowired
    private RedisTemplate redisTemplate;

    //登陆的方法
    @RequestMapping("login")
    //收参时：可以收集到请求？拼接的参数，参数是url上传递，get请求能收到参数
    //post收不到参数，是因为post请求传参，不是通过url,是通过请求体传参
    //指明controller收集请求体的参数
    public Map<String,Object> login(@RequestBody Admin admin, HttpServletRequest request){
//            System.out.println(request.getSession(true).getId());
        //响应给后端   登陆成功 还是 登陆失败
        Map<String,Object> login = adminService.login(admin,request);
        return login;

    }
}
